﻿using System.Data.Entity;
using Database.Models;

namespace Database.Context
{
    public class Context : DbContext
    {
        public DbSet<User> Users { get; set; }

        public DbSet<Role> Roles { get; set; }

        public DbSet<Phong> Phongs { get; set; }

        public DbSet<Doi> Dois { get; set; }

        public DbSet<ThanhPhanKinhTeCoSo> ThanhPhanKinhTeCoSos { get; set; }

        public DbSet<HinhThucDauTuCoSo> HinhThucDauTuCoSos { get; set; }

        public DbSet<CoQuanQuanLyPCCC> CoQuanQuanLyPCCCs { get; set; }

        public DbSet<CapQuanLyHanhChinhCoSo> CapQuanLyHanhChinhCoSos { get; set; }

        public DbSet<CanBo> CanBoQuanLies { get; set; }

        public DbSet<NganhLinhVucCoSo> NganhLinhVucs { get; set; }

        public DbSet<LoaiHinhHoatDongCoSo> LoaiHinhHoatDongs { get; set; }

        public DbSet<NhomPhuongTienPCCCCoSo> NhomPhuongTienCoSoes { get; set; }
        public DbSet<PhanLoaiChiTietPhuongTienPCCCCoSo> PhanLoaiChiTietPhuongTienCoSoes { get; set; }
        public DbSet<PhuongTienCoSo> PhuongTienCoSoes { get; set; }

        public DbSet<NhomPhuongTien> NhomPhuongTiens { get; set; }
        public DbSet<PhanLoaiChiTietPhuongTien> PhanLoaiChiTietPhuongTiens { get; set; }
        public DbSet<PhuongTien> PhuongTiens { get; set; }

        public DbSet<LoaiCoSo> LoaiCoSos { get; set; }
        public DbSet<ThoiDiem> ThoiDiems { get; set; }
        public DbSet<QuanHuyen> QuanHuyens { get; set; }

        //Tham Duyet PCCC
        public DbSet<ThamDuyetPCCC> ThamDuyets { get; set; }
        public DbSet<VanBanThamDuyetPCCC> VanBanThamDuyets { get; set; }
        public DbSet<CoQuanCapVanBanThamDuyet> CoQuanCapVanBanThamDuyets { get; set; }

        //Hang Muc
        public DbSet<HangMuc> HangMucs { get; set; }
        public DbSet<BacChiuLua> BacChiuLuas { get; set; }
        public DbSet<HangSanXuat> HangSanXuats { get; set; }
        //Nguon Nuoc
        public DbSet<NguonNuoc> NguonNuocs { get; set; }
        public DbSet<LoaiNguonNuoc> LoaiNguonNuocs { get; set; }
        public DbSet<PhanLoaiChiTietNguonNuoc> PhanLoaiChiTietNguonNuocs { get; set; }
        //Tuyen truyen huan luyen
        public DbSet<TuyenTruyenHuanLuyen> TuyenTruyenHuanLuyens { get; set; }
        //Kiem Tra An Toan
        public DbSet<KiemTraAnToan> KiemTraAnToans { get; set; }
        //Nhom Hanh Vi
        public DbSet<NhomHanhVi> NhomHanhVis { get; set; }
        //XuLyViPham
        public DbSet<XuLyViPham> XuLyViPhams { get; set; }

        public DbSet<NguyenNhanChay> NguyenNhanChays { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<User>().
                HasOptional(u => u.CreatedBy).
                WithMany().
                HasForeignKey(u => u.CreatedById);

            modelBuilder.Entity<User>().
                HasOptional(u => u.ModifiedBy).
                WithMany().
                HasForeignKey(u => u.ModifiedById);
        }
    }
}